# coding:utf-8

numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print(len(numbers) - 1)  # 列表的最大索引
print(numbers[9])
print(id(numbers))

print('获取列表完整数据：', id(numbers[:]))  # [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print('另一种获取列表完整数据的方法：', numbers[0:])  # [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print('第三种获取列表数据的方法：', numbers[0:-1])  # [1, 2, 3, 4, 5, 6, 7, 8, 9]

print('列表的反序：', numbers[::-1])  # [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
print('列表的反项获取：', numbers[-3:-1])  # [8, 9]
print('步长获取切片：', numbers[0:8:2])  # [1, 3, 5, 7]
print('切片生成空列表：', numbers[0:0])  # []

new_numbers = numbers[:4]
print(new_numbers)  # [1, 2, 3, 4]

numbers[3] = 'code'
print(numbers)  # [1, 2, 3, 'code', 5, 6, 7, 8, 9, 10]
numbers[2:5] = ['a', 'b', 'c']
print(numbers)  # [1, 2, 'a', 'b', 'c', 6, 7, 8, 9, 10]

# print(numbers.index('code'))  # ValueError: 'code' is not in list

item = numbers.pop(4)
print(item, numbers, len(numbers))  # c [1, 2, 'a', 'b', 6, 7, 8, 9, 10] 9

del numbers[4]
print(numbers)  # [1, 2, 'a', 'b', 7, 8, 9, 10]

tuple_test = (1, 2, 3)
# del tuple_test[2]   # TypeError: 'tuple' object doesn't support item deletion  元组的元素不能修改和删除
del tuple_test  # 元组可以删除
